package cc.rengu.igas.bsps.biz.service.impl;

import cc.rengu.igas.bsps.common.enums.RespCodeEnum;
import cc.rengu.igas.bsps.facade.MchntUserService;
import cc.rengu.igas.bsps.facade.request.*;
import cc.rengu.igas.bsps.facade.response.*;
import cc.rengu.igas.bsps.facade.result.Result;
import cc.rengu.oltp.service.model.BizException;
import cc.rengu.oltp.service.model.DubboResult;
import cc.rengu.oltp.service.realize.DubboService;
import cc.rengu.oltp.service.realize.impl.DubboServiceImpl;
import cc.rengu.oltp.utility.util.ConvertUtil;
import cc.rengu.utility.log.RgLog;
import cc.rengu.utility.log.RgLogger;

import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;

/**
 * 商户用户服务功能.
 */
public class MchntUserServiceImpl implements MchntUserService {

    RgLogger rglog = RgLog.getLogger(this.getClass().getName());

    @Override
    public Result<GetUserAuthCodeResponse> getUserAuthCode(GetUserAuthCodeRequest getUserAuthCodeRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<GetUserAuthCodeResponse> bspResult = new Result<>();
        GetUserAuthCodeResponse getUserAuthCodeResponse = new GetUserAuthCodeResponse();
        getUserAuthCodeResponse.setHeader(getUserAuthCodeRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(getUserAuthCodeRequest, GetUserAuthCodeResponse.class);
            getUserAuthCodeResponse = (GetUserAuthCodeResponse) dubboResult.getResult();
            getUserAuthCodeResponse.setRespCode(dubboResult.getRespCode());
            getUserAuthCodeResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("获取用户授权码失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                getUserAuthCodeResponse.setRespCode(((BizException) e).getCode());
                getUserAuthCodeResponse.setRespDesc(e.getMessage());
            } else {
                getUserAuthCodeResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                getUserAuthCodeResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(getUserAuthCodeResponse);
        return bspResult;
    }

    @Override
    public Result<GetUserAuthInfoResponse> getUserAuthInfo(GetUserAuthInfoRequest getUserAuthInfoRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<GetUserAuthInfoResponse> bspResult = new Result<>();
        GetUserAuthInfoResponse getUserAuthInfoResponse = new GetUserAuthInfoResponse();
        getUserAuthInfoResponse.setHeader(getUserAuthInfoRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(getUserAuthInfoRequest, GetUserAuthInfoResponse.class);
            getUserAuthInfoResponse = (GetUserAuthInfoResponse) dubboResult.getResult();
            getUserAuthInfoResponse.setRespCode(dubboResult.getRespCode());
            getUserAuthInfoResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("获取用户授权信息失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                getUserAuthInfoResponse.setRespCode(((BizException) e).getCode());
                getUserAuthInfoResponse.setRespDesc(e.getMessage());
            } else {
                getUserAuthInfoResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                getUserAuthInfoResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(getUserAuthInfoResponse);
        return bspResult;
    }

    @Override
    public Result<GetUserInfoListResponse> getUserInfoList(GetUserInfoListRequest getUserInfoListRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<GetUserInfoListResponse> bspResult = new Result<>();
        GetUserInfoListResponse getUserInfoListResponse = new GetUserInfoListResponse();
        getUserInfoListResponse.setHeader(getUserInfoListRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(getUserInfoListRequest, GetUserInfoListResponse.class);
            getUserInfoListResponse = (GetUserInfoListResponse) dubboResult.getResult();
            getUserInfoListResponse.setRespCode(dubboResult.getRespCode());
            getUserInfoListResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("手机号获取用户列表失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                getUserInfoListResponse.setRespCode(((BizException) e).getCode());
                getUserInfoListResponse.setRespDesc(e.getMessage());
            } else {
                getUserInfoListResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                getUserInfoListResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(getUserInfoListResponse);
        return bspResult;
    }

    @Override
    public Result<UserLogInOutResponse> userLogInOut(UserLogInOutRequest userLogInOutRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UserLogInOutResponse> bspResult = new Result<>();
        UserLogInOutResponse userLogInOutResponse = new UserLogInOutResponse();
        userLogInOutResponse.setHeader(userLogInOutRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(userLogInOutRequest, UserLogInOutResponse.class);
            userLogInOutResponse = (UserLogInOutResponse) dubboResult.getResult();
            userLogInOutResponse.setRespCode(dubboResult.getRespCode());
            userLogInOutResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("用户登录登出失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                userLogInOutResponse.setRespCode(((BizException) e).getCode());
                userLogInOutResponse.setRespDesc(e.getMessage());
            } else {
                userLogInOutResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                userLogInOutResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(userLogInOutResponse);
        return bspResult;
    }

    @Override
    public Result<RegisterUserNameCheckResponse> registerUserNameCheck(RegisterUserNameCheckRequest registerUserNameCheckRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<RegisterUserNameCheckResponse> bspResult = new Result<>();
        RegisterUserNameCheckResponse registerUserNameCheckResponse = new RegisterUserNameCheckResponse();
        registerUserNameCheckResponse.setHeader(registerUserNameCheckRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(registerUserNameCheckRequest, RegisterUserNameCheckResponse.class);
            registerUserNameCheckResponse = (RegisterUserNameCheckResponse) dubboResult.getResult();
            registerUserNameCheckResponse.setRespCode(dubboResult.getRespCode());
            registerUserNameCheckResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("注册用户名校验失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                registerUserNameCheckResponse.setRespCode(((BizException) e).getCode());
                registerUserNameCheckResponse.setRespDesc(e.getMessage());
            } else {
                registerUserNameCheckResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                registerUserNameCheckResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(registerUserNameCheckResponse);
        return bspResult;
    }

    @Override
    public Result<UserPasswordResetResponse> userPasswordReset(UserPasswordResetRequest userPasswordResetRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UserPasswordResetResponse> bspResult = new Result<>();
        UserPasswordResetResponse userPasswordResetResponse = new UserPasswordResetResponse();
        userPasswordResetResponse.setHeader(userPasswordResetRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(userPasswordResetRequest, UserPasswordResetResponse.class);
            userPasswordResetResponse = (UserPasswordResetResponse) dubboResult.getResult();
            userPasswordResetResponse.setRespCode(dubboResult.getRespCode());
            userPasswordResetResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("用户密码重置失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                userPasswordResetResponse.setRespCode(((BizException) e).getCode());
                userPasswordResetResponse.setRespDesc(e.getMessage());
            } else {
                userPasswordResetResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                userPasswordResetResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(userPasswordResetResponse);
        return bspResult;
    }

    @Override
    public Result<CashierAddResponse> cashierAdd(CashierAddRequest cashierAddRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<CashierAddResponse> bspResult = new Result<>();
        CashierAddResponse cashierAddResponse = new CashierAddResponse();
        cashierAddResponse.setHeader(cashierAddRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(cashierAddRequest, CashierAddResponse.class);
            cashierAddResponse = (CashierAddResponse) dubboResult.getResult();
            cashierAddResponse.setRespCode(dubboResult.getRespCode());
            cashierAddResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("新增收银员失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                cashierAddResponse.setRespCode(((BizException) e).getCode());
                cashierAddResponse.setRespDesc(e.getMessage());
            } else {
                cashierAddResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                cashierAddResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(cashierAddResponse);
        return bspResult;
    }

    @Override
    public Result<CashierModifyResponse> cashierModify(CashierModifyRequest cashierModifyRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<CashierModifyResponse> bspResult = new Result<>();
        CashierModifyResponse cashierModifyResponse = new CashierModifyResponse();
        cashierModifyResponse.setHeader(cashierModifyRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(cashierModifyRequest, CashierModifyResponse.class);
            cashierModifyResponse = (CashierModifyResponse) dubboResult.getResult();
            cashierModifyResponse.setRespCode(dubboResult.getRespCode());
            cashierModifyResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("收银员信息修改失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                cashierModifyResponse.setRespCode(((BizException) e).getCode());
                cashierModifyResponse.setRespDesc(e.getMessage());
            } else {
                cashierModifyResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                cashierModifyResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(cashierModifyResponse);
        return bspResult;
    }

    @Override
    public Result<CashierUnBindResponse> cashierUnBind(CashierUnBindRequest cashierUnBindRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<CashierUnBindResponse> bspResult = new Result<>();
        CashierUnBindResponse cashierUnBindResponse = new CashierUnBindResponse();
        cashierUnBindResponse.setHeader(cashierUnBindRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(cashierUnBindRequest, CashierUnBindResponse.class);
            cashierUnBindResponse = (CashierUnBindResponse) dubboResult.getResult();
            cashierUnBindResponse.setRespCode(dubboResult.getRespCode());
            cashierUnBindResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("收银员解绑失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                cashierUnBindResponse.setRespCode(((BizException) e).getCode());
                cashierUnBindResponse.setRespDesc(e.getMessage());
            } else {
                cashierUnBindResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                cashierUnBindResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(cashierUnBindResponse);
        return bspResult;
    }

    @Override
    public Result<CashierMsgSettingResponse> cashierMsgSetting(CashierMsgSettingRequest cashierMsgSettingRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<CashierMsgSettingResponse> bspResult = new Result<>();
        CashierMsgSettingResponse cashierMsgSettingResponse = new CashierMsgSettingResponse();
        cashierMsgSettingResponse.setHeader(cashierMsgSettingRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(cashierMsgSettingRequest, CashierMsgSettingResponse.class);
            cashierMsgSettingResponse = (CashierMsgSettingResponse) dubboResult.getResult();
            cashierMsgSettingResponse.setRespCode(dubboResult.getRespCode());
            cashierMsgSettingResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("收银员信息关联设置失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                cashierMsgSettingResponse.setRespCode(((BizException) e).getCode());
                cashierMsgSettingResponse.setRespDesc(e.getMessage());
            } else {
                cashierMsgSettingResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                cashierMsgSettingResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(cashierMsgSettingResponse);
        return bspResult;
    }

    @Override
    public Result<MobileBankAuthLoginResponse> mobileBankAuthLogin(MobileBankAuthLoginRequest mobileBankAuthLoginRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<MobileBankAuthLoginResponse> bspResult = new Result<>();
        MobileBankAuthLoginResponse mobileBankAuthLoginResponse = new MobileBankAuthLoginResponse();
        mobileBankAuthLoginResponse.setHeader(mobileBankAuthLoginRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(mobileBankAuthLoginRequest, MobileBankAuthLoginResponse.class);
            mobileBankAuthLoginResponse = (MobileBankAuthLoginResponse) dubboResult.getResult();
            mobileBankAuthLoginResponse.setRespCode(dubboResult.getRespCode());
            mobileBankAuthLoginResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("手机银行认证登录失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                mobileBankAuthLoginResponse.setRespCode(((BizException) e).getCode());
                mobileBankAuthLoginResponse.setRespDesc(e.getMessage());
            } else {
                mobileBankAuthLoginResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                mobileBankAuthLoginResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(mobileBankAuthLoginResponse);
        return bspResult;
    }

    @Override
    public Result<MobileBankWechatAuthBindMchntResponse> mobileBankWechatAuthBindMchnt(MobileBankWechatAuthBindMchntRequest mobileBankWechatAuthBindMchntRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<MobileBankWechatAuthBindMchntResponse> bspResult = new Result<>();
        MobileBankWechatAuthBindMchntResponse mobileBankWechatAuthBindMchntResponse = new MobileBankWechatAuthBindMchntResponse();
        mobileBankWechatAuthBindMchntResponse.setHeader(mobileBankWechatAuthBindMchntRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(mobileBankWechatAuthBindMchntRequest, MobileBankWechatAuthBindMchntResponse.class);
            mobileBankWechatAuthBindMchntResponse = (MobileBankWechatAuthBindMchntResponse) dubboResult.getResult();
            mobileBankWechatAuthBindMchntResponse.setRespCode(dubboResult.getRespCode());
            mobileBankWechatAuthBindMchntResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("手机银行微信授权绑定商户失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                mobileBankWechatAuthBindMchntResponse.setRespCode(((BizException) e).getCode());
                mobileBankWechatAuthBindMchntResponse.setRespDesc(e.getMessage());
            } else {
                mobileBankWechatAuthBindMchntResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                mobileBankWechatAuthBindMchntResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(mobileBankWechatAuthBindMchntResponse);
        return bspResult;
    }

    @Override
    public Result<MobileBankMchntNoBindMchntResponse> mobileBankMchntNoBindMchnt(MobileBankMchntNoBindMchntRequest mobileBankMchntNoBindMchntRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<MobileBankMchntNoBindMchntResponse> bspResult = new Result<>();
        MobileBankMchntNoBindMchntResponse mobileBankMchntNoBindMchntResponse = new MobileBankMchntNoBindMchntResponse();
        mobileBankMchntNoBindMchntResponse.setHeader(mobileBankMchntNoBindMchntRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(mobileBankMchntNoBindMchntRequest, MobileBankMchntNoBindMchntResponse.class);
            mobileBankMchntNoBindMchntResponse = (MobileBankMchntNoBindMchntResponse) dubboResult.getResult();
            mobileBankMchntNoBindMchntResponse.setRespCode(dubboResult.getRespCode());
            mobileBankMchntNoBindMchntResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("手机银行商户号绑定商户失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                mobileBankMchntNoBindMchntResponse.setRespCode(((BizException) e).getCode());
                mobileBankMchntNoBindMchntResponse.setRespDesc(e.getMessage());
            } else {
                mobileBankMchntNoBindMchntResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                mobileBankMchntNoBindMchntResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(mobileBankMchntNoBindMchntResponse);
        return bspResult;
    }

    @Override
    public Result<GenerateLoginOrderResponse> generateLoginOrder(GenerateLoginOrderRequest generateLoginOrderRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<GenerateLoginOrderResponse> bspResult = new Result<>();
        GenerateLoginOrderResponse generateLoginOrderResponse = new GenerateLoginOrderResponse();
        generateLoginOrderResponse.setHeader(generateLoginOrderRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(generateLoginOrderRequest, GenerateLoginOrderResponse.class);
            generateLoginOrderResponse = (GenerateLoginOrderResponse) dubboResult.getResult();
            generateLoginOrderResponse.setRespCode(dubboResult.getRespCode());
            generateLoginOrderResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("生成登录订单失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                generateLoginOrderResponse.setRespCode(((BizException) e).getCode());
                generateLoginOrderResponse.setRespDesc(e.getMessage());
            } else {
                generateLoginOrderResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                generateLoginOrderResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(generateLoginOrderResponse);
        return bspResult;
    }

    @Override
    public Result<LoginOrderStatusQueryResponse> loginOrderStatusQuery(LoginOrderStatusQueryRequest loginOrderStatusQueryRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<LoginOrderStatusQueryResponse> bspResult = new Result<>();
        LoginOrderStatusQueryResponse loginOrderStatusQueryResponse = new LoginOrderStatusQueryResponse();
        loginOrderStatusQueryResponse.setHeader(loginOrderStatusQueryRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(loginOrderStatusQueryRequest, LoginOrderStatusQueryResponse.class);
            loginOrderStatusQueryResponse = (LoginOrderStatusQueryResponse) dubboResult.getResult();
            loginOrderStatusQueryResponse.setRespCode(dubboResult.getRespCode());
            loginOrderStatusQueryResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("登录订单查证失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                loginOrderStatusQueryResponse.setRespCode(((BizException) e).getCode());
                loginOrderStatusQueryResponse.setRespDesc(e.getMessage());
            } else {
                loginOrderStatusQueryResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                loginOrderStatusQueryResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(loginOrderStatusQueryResponse);
        return bspResult;
    }

    @Override
    public Result<WechatScanCodeLoginResponse> wechatScanCodeLogin(WechatScanCodeLoginRequest wechatScanCodeLoginRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<WechatScanCodeLoginResponse> bspResult = new Result<>();
        WechatScanCodeLoginResponse wechatScanCodeLoginResponse = new WechatScanCodeLoginResponse();
        wechatScanCodeLoginResponse.setHeader(wechatScanCodeLoginRequest.getHeader());
        try {
            DubboResult dubboResult = dubboService.callBizService(wechatScanCodeLoginRequest, WechatScanCodeLoginResponse.class);
            wechatScanCodeLoginResponse = (WechatScanCodeLoginResponse) dubboResult.getResult();
            wechatScanCodeLoginResponse.setRespCode(dubboResult.getRespCode());
            wechatScanCodeLoginResponse.setRespDesc(dubboResult.getRespDesc());
            bspResult.setSuccess(dubboResult.isSuccess());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("微信扫码登录失败:<{}>", byteArrayOutputStream.toString());
            bspResult.setSuccess(false);
            if (e instanceof BizException) {
                wechatScanCodeLoginResponse.setRespCode(((BizException) e).getCode());
                wechatScanCodeLoginResponse.setRespDesc(e.getMessage());
            } else {
                wechatScanCodeLoginResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                wechatScanCodeLoginResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        bspResult.setResult(wechatScanCodeLoginResponse);
        return bspResult;
    }
}
